/*
dictionariesmanager.h
(c) 2010 Yury Hamenkov
This file is part of qWordCards.

qWordCards is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

qWordCards is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with qWordCards. If not, see <http://www.gnu.org/licenses/>.
*/

/*
  DictionariesManager class manages the list of avaliable dictionaries. In scans './dicts' directory
  and searches for .idx and .dict.dz files. Dictionaries are loaded in a separate thread.
*/


#ifndef DICTIONARIESMANAGER_H
#define DICTIONARIESMANAGER_H

#include <QObject>
#include <QList>
#include <QDir>
#include <QAction>
#include <QMap>
#include <QMenu>

#include "dictionary.h"

namespace qWordCards{
	
	//class Dictionary;
	class DictionaryLoadThread;
	class Word;
	
	
	class DictionariesManager : public QObject
	{
	Q_OBJECT
	public:
		explicit DictionariesManager(QObject *parent = 0);
		~DictionariesManager();
		
		void ReloadDictionaries();
		
		
		int DictionariesCount() const;
		int WordsCount() const;
		
		QMap <QString, bool> GetDictionariesActivity() const;
		
		void SetFavourite(QString s, bool t);
		void SetKnown(QString s, bool t);
		void SetSuspended(QString s, bool t);
		
		int FavouriteWordsCount() const;
		int KnownWordsCount() const;
		int OrdinalWordsCount() const;
		
		Word GetWord(WordType type) const;
		
		Dictionary* operator[](int index);
		Dictionary* operator[](QString name);
		
		QMenu* GetMenu() const;
	
	private:
		DictionaryLoadThread*	_thread;
		QList<Dictionary*>		_dicts;
		QMenu*					_menu;
		
		void ScanDir(QDir dir);
	
	signals:
		void sg_LoadingComplete();
		void sg_DictionaryCreated(const Dictionary* const d);
		void sg_AboutToDeleteDictionary(const Dictionary* const d);
	
	public slots:
	private slots:
		void sl_DictionaryLoadingCompleted();
		void sl_SelectDictPressed();
	
	};
}
#endif // DICTIONARIESMANAGER_H
